//
//  Music.m
//  音乐播放(AVFoundation版)
//
//  Created by dllo on 15/9/23.
//  Copyright (c) 2015年 直到世界的尽头. All rights reserved.
//

#import "Music.h"
static Music *music;

@interface Music ()

@end

@implementation Music

+(Music *)shareInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        music = [[Music alloc] init];
        
    });
    return music;
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
{
    //NSLog(@"%@", change);
}

-(void)playMusicWith:(NSString *)urlString
{
    //NSLog(@"%@", urlString);
    if ([_currentURL isEqualToString:urlString]) {
        
    }
    else{
        [_myPlayer pause];
        _myPlayer = [[AVPlayer alloc] initWithURL:[NSURL URLWithString:urlString]];
        [_myPlayer play];
        _currentURL = urlString;
    }
    
}

@end
